[ `command -v tsu` ] || pkg i tsu -y
[ `command -v proot` ] || pkg install proot -y
[ `command -v pulseaudio` ] || pkg install pulseaudio -y
[[ `pkg list-all|grep pulseaudio` ]] || pkg i pulseaudio -y
[ `command -v wget` ] || pkg i wget -y

TYLJ="https://189.ly93.cc/R3iUbaZbqqIr/51387114668985702?accessToken=FDE7C87A2949966E1F6CD750AABFA0AE"
[[ `curl -s $TYLJ|grep 解析分享信息` ]] && echo 链接过期，联系楼主 && exit
cd
[[ ! `ls -l|grep file.tar.gz|awk '{print $5}'|grep 388607799` ]] && sudo rm -rf file.tar.gz
[ -e alpine ] || mkdir alpine
[ -r file.tar.gz ] || wget -O file.tar.gz --no-check-certificate $TYLJ
if [ -e alpine/ql ];then
echo "已解压"
else
[ -r file.tar.gz ] && sudo tar -xvf file.tar.gz -C alpine && \
echo "解压成功"
[[ `ls -l alpine/boot/init.sh|awk '{print $1}'|grep 'rwxrwxrwx'` ]] || sudo chmod -R 777 alpine
fi
grep "bash ql.sh" ~/.bashrc || Brc="alpine"
if [ alpine == $Brc ];then
cat > ~/.bashrc <<-EOF
ht=\`sudo ps -ef |grep /ql/build/app.js|grep -v "grep" | wc -l\`
if [ 0 == \$ht ];then
bash ~/ql.sh
fi
EOF
fi
#自启设置
sudo grep -qs init.sh alpine/etc/profile.d/motd.sh || echo -e 'ht=`ps -ef |grep /ql/build/app.js|grep -v "grep" | wc -l`\nif [ 0 == $ht ];then\nnohup bash /boot/init.sh 2>&1 & \nfi' >>alpine/etc/profile.d/motd.sh && \
echo "自启写入成功"

#写入启动文件
cat > ~/ql.sh <<-EOF
#!/bin/bash
#pkg update && pkg install wget && pkg install proot && pkg install ncurses-utils && pkg install pulseaudio
cd .
## unset LD_PRELOAD in case termux-exec is installed
pulseaudio --start &
echo "" &
echo "(以Root:sudo 权限正在运行)欢迎来到alpine-ql系统" &
unset LD_PRELOAD
command="sudo "
command+="proot"
command+=" --kill-on-exit"
command+=" --link2symlink"
command+=" -S alpine"
command+=""
command+=" -b alpine/root:/dev/shm"
## uncomment the following line to have access to the home directory of termux
#command+=" -b /data/data/com.termux/files/home:/root"
## uncomment the following line to mount /sdcard directly to /
command+=" -b /sdcard"
command+=" -w /root"
command+=" /usr/bin/env -i"
command+=" HOME=/root"
command+=" USER=root"
command+=" PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin:/usr/games:/usr/local/games"
command+=" TERM=xterm-256color"
command+=" LANG=C.UTF-8"
$ZDYZQ
command+=" /bin/bash --login"
com="\$@"
if [ -z "\$1" ];then
    exec \$command
else
    \$command -c "\$com"
fi
EOF
echo "执行文件为: ql.sh""[ bash ql.sh ]"
bash ~/ql.sh